package org.nidy.programexercise.MapCollection;

import java.util.TreeMap;

public class TreeMapCollection {
    public static void main(String[] args) {
        String s = "aafafjakdfjafdaljfakdfalkjfaljfasfklahgghakhadflkahdgahgh";
        TreeMap<Character, Integer> map = new TreeMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (map.containsKey(c)) {
                Integer count = map.get(c);
                count++;
                map.put(c, count);
            } else {
                map.put(c, 1);
            }
        }
        map.forEach((k, v) -> System.out.println(k + ":" + v));
    }
}
